import sun.misc.Signal;

/*
 * @Author: qianmingtian
 * @Date: 2020-07-06 16:24:36
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-06 16:31:44
 * @FilePath: \qianmingtian.github.io\code\java\singleInstance02.java
 */ 
//创建型单例实现

// 1.构造方法私有化
// 2.提供获取实例的方法
// 3.提供实例的应用
class Single{
    private static Single s = null;
    private Single(){

    }

    public static Single getInstance(){
        if(s == null){
            s = new Single();
        }
        return s;
    }


}
public class SingleInstance02 {
    public static void main(String[] args) {
        Single s1 = Single.getInstance();
        Single s2 = Single.getInstance();

        if(s1 == s2){
            System.out.println("true");
        }

    }
    
}/*
 * @Author: qianmingtian
 * @Date: 2020-07-06 16:24:36
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-06 16:24:37
 * @FilePath: \qianmingtian.github.io\code\java\SingleInstance02.java
 */ 
